<template>
  <el-drawer title="" :visible.sync="visible" :wrapperClosable="false"
             size="60%" append-to-body class="JNPF-common-drawer">
    <div class="JNPF-flex-main">
      <div class="dynamicForm dynamicDetail">
        <el-form ref="formRef" :model="dataForm" size="small" label-width="100px" label-position="right">
          <template v-if="!loading">
            <el-col :span="24">
              <jnpf-form-tip-item label-width="0">
                <JnpfText
                  :textStyle='{"color":"#000000","font-weight":"bold","text-decoration":"none","font-size":24,"line-height":32,"font-style":"normal","text-align":"center"}'
                  :closable="false" content="">
                </JnpfText>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label-width="0">
                <JnpfText
                  :textStyle='{"color":"#000000","font-weight":"bold","text-decoration":"none","font-size":24,"line-height":32,"font-style":"normal","text-align":"left"}'
                  :closable="false" content="一、基本信息">
                </JnpfText>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label="服务商类型">
                <div v-for="item in dataForm.tableField127" :key="item.id">
                  <p>{{item.serverType}}</p>
                </div>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label="单位名称"
                                  prop="enterpriseName">
                <p>{{ dataForm.enterpriseName }}</p>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label="信用代码"
                                  prop="enterpriseCreditCode">
                <p>{{ dataForm.enterpriseCreditCode }}</p>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label="单位地址"
                                  prop="enterpriseAddress">
                <p>{{ dataForm.enterpriseAddress }}</p>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label="成立时间"
                                  prop="enterpriseStart">
                <p>{{ dataForm.enterpriseStart }}</p>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label="注册资本"
                                  prop="registeredCapital">
                <JnpfNumber v-model="dataForm.registeredCapital"
                            placeholder="请输入" disabled
                            :step="1" addonAfter="万元">
                </JnpfNumber>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="8">
              <jnpf-form-tip-item label="联系人"
                                  prop="contactPerson">
                <p>{{ dataForm.contactPerson }}</p>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="8">
              <jnpf-form-tip-item label="联系方式"
                                  prop="contactInformation">
                <p>{{ dataForm.contactInformation }}</p>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="8">
              <jnpf-form-tip-item label="电子邮箱"
                                  prop="email">
                <p>{{ dataForm.email }}</p>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label="单位简介"
                                  prop="companyNote">
                <p>{{ dataForm.companyNote }}</p>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label="文件上传"
                                  prop="file" v-if="dataForm.file !=null">
                <JnpfUploadFile v-model="dataForm.file"
                                disabled
                                detailed :fileSize="10" sizeUnit="MB" :limit="9" pathType="defaultPath" :isAccount="0"
                                buttonText="点击上传">
                </JnpfUploadFile>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label-width="0">
                <JnpfText
                  :textStyle='{"color":"#000000","font-weight":"bold","text-decoration":"none","font-size":24,"line-height":32,"font-style":"normal","text-align":"left"}'
                  :closable="false" content="二、产品信息">
                </JnpfText>
              </jnpf-form-tip-item>
            </el-col>
            <el-col :span="24">
              <jnpf-form-tip-item label-width="0">
                <div class="JNPF-common-title">
                </div>
                <el-table :data="dataForm.tableField107" size='mini'>
                  <el-table-column type="index" width="50" label="序号" align="center"/>
                  <el-table-column prop="productName" label="产品名称">
                    <template slot-scope="scope">
                      <a @click="toProductDetail(scope.row.id)" style="color: #4b9bff">{{ scope.row.productName }}</a>
                    </template>
                  </el-table-column>
                  <el-table-column prop="serviceIndustry" label="服务行业">
                    <template slot-scope="scope">
                      <p>{{ scope.row.serviceIndustry }}</p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="productType" label="产品类别(大类)">
                    <template slot-scope="scope">
                      <p>{{ scope.row.productType }}</p>
                    </template>
                  </el-table-column>
                </el-table>
              </jnpf-form-tip-item>
            </el-col>

          </template>
        </el-form>
      </div>
      <div class="drawer-footer">
        <el-button @click="visible = false" type="primary"> 取 消</el-button>
      </div>
      <formProduct v-if="formVisible" ref="form" @close="closeForm"/>
    </div>
  </el-drawer>
</template>
<script>
import request from '@/utils/request'
import formProduct from './DetailProduct'
import {getConfigData} from '@/api/onlineDev/visualDev'
import jnpf from '@/utils/jnpf'
import Detail from '@/views/basic/dynamicModel/list/detail'
import {thousandsFormat} from "@/components/Generator/utils/index"

export default {
  components: {Detail,formProduct},
  props: [],
  data() {
    return {
      visible: false,
      formVisible: false,
      detailVisible: false,
      loading: false,
      dataForm: {
        enterprisecreditcode: '',
        enterpriseName: '',
        enterpriseCreditCode: '',
        enterpriseAddress: '',
        enterpriseStart: '',
        registeredCapital: '',
        contactPerson: '',
        contactInformation: '',
        email: '',
        companyNote: '',
        file: [],
        creatoruserid: "",
        creatortime: "",
        lastmodifyuserid: "",
        lastmodifytime: "",
        fz_supply_market_productList: [],
        fz_supply_market_regList: [],
      },

      serviceIndustryOptions: [{"fullName": "汽车制造业", "id": "1"}, {
        "fullName": "轻工纺织业",
        "id": "2"
      }, {"fullName": "计算机、通信和其他电子设备制造业", "id": "3"}],
      serviceIndustryProps: {"label": "fullName", "value": "id"},
      productTypeOptions: [{"fullName": "软件系统及SaaS化应用类", "id": "1"}, {
        "fullName": "基础设施类",
        "id": "2"
      }, {"fullName": "生产设备类", "id": "3"}],
      productTypeProps: {"label": "fullName", "value": "id"},
    }
  },
  computed: {},
  watch: {},
  created() {

  },
  mounted() {
  },
  methods: {
    closeForm() {
      this.formVisible = false;
    },
    toProductDetail(id) {
      this.formVisible = true
      this.$nextTick(() => {
        this.$refs.form.init(id)
      })
    },
    toDetail(defaultValue, modelId) {
      if (!defaultValue) return
      getConfigData(modelId).then(res => {
        if (!res.data || !res.data.formData) return
        let formData = JSON.parse(res.data.formData)
        formData.popupType = 'general'
        this.detailVisible = true
        this.$nextTick(() => {
          this.$refs.Detail.init(formData, modelId, defaultValue)
        })
      })
    },
    dataInfo(dataAll) {
      let _dataAll = dataAll
      this.dataForm = _dataAll
    },

    init(id) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true
          request({
            url: '/api/example/Fz_supply_market/detail/' + this.dataForm.id,
            method: 'get'
          }).then(res => {
            this.dataInfo(res.data)
            this.loading = false
          })
        }

      })
    },
  },
}

</script>
